import Lib from "../core/lib.js"
const lib = new Lib();
const HttpModule = function() {
	//测试
	this.testRequset = async function() {
		return await lib.$get({
			url: {
				base: false, //表示不使用baseUrl
				url: "http://www.baidu.com"
			}
		})
	};
	this.authToken = async function() {
		return await lib.$post({
			url: {
				base:true,
				url: "/authToken"
			}
		})
	};
	this.loginByPhone = async function(phone,code) {
		const token=await lib.$post({
			url: '/loginByPhone',
			data:{
				phone,code
			}
		})
		await lib.setToken(token.data.token)//设置缓存
		uni.hideLoading()
		return token
	};
	this.loginByMiniCode = async function(data) {
		const token=await lib.$post({
			url: '/code2openid',
			data
		})
		await lib.setToken(token.data.token)//设置缓存
		uni.hideLoading()
		return token.data.token
	};
	//获取附近站点1
	this.getMyStations= async function (data) {
	    return await lib.$post({
	      url: '/Sites',
	      method: 'post',
	      data
	    });
	};
	//获取附近站点2
	this.getMyStations2= async function (data) {
		const stations=await lib.$get2({
	      url: '/getStationByLocal',
	      method: 'get',
	      data
	    });
		console.log(stations)
	    return {data:{sitesD:stations.data.data}}
	};
	//搜索公交1
	this.getlineInfo= async function(data) {
	    return await lib.$post({
	      url: '/getlineInfo',
	      method: 'post',
	      data
	    });
	  };
	  //搜索公交2
	this.getlineInfo2= async function(data) {
	   const getlineInfo =await lib.$get2({
	      url: '/getStationByLineName',
	      data
	    });
		console.log(getlineInfo)
		return getlineInfo
	  };
	  //获取站点详情1
	 this.lineDetial= async function(data) {
	      return await lib.$post({
	        url: '/lineDetial',
	        method: 'post',
	        data
	      });
	  }; 
	  //获取站点详情2
	  // data:{lineNo,isUpDown}
	  this.lineDetial2= async function(data) {
	      return await lib.$get2({
	        url: `/getStationByLine`,
	        data
	      });
	  }; 
	  //获取实时公交2
	  // {lineNo,isUpDown}
	  this.getBusInfoByLineNo2= async function(data) {
	      return await lib.$get2({
	        url: `/getBusInfoByLineNoNew/${data.lineNo}/${data.isUpDown}/${data.source}`
	      });
	  };
	  //获取所有公交
	  this.getBusInfo= async function() {
	      return await lib.$get2({
	        url: `/getBusInfo`
	      });
	  };
	   this.newFeedBack = async function (data) {
	      return await lib.$post({
	        url: '/newFeedBack',
	        method: 'post',
	        data
	      });
	    };
	  this.customBus= async function(data) {
	    await lib.$post({
	      url: '/customBus',
	      method: 'post',
	      data: data
	    });
	  };
	   this.getBusList = async function() {
	      return await lib.$post({
	        url: '/getBusList',
	        method: 'post'
	      });
	    }
		this.delBusOrder = async function(id) {
	      return await lib.$post({
	        url: '/delBusOrder',
	        method: 'post',
			data:{id}
	      });
	    }
		this.newCode = async function(phone) {
	      return await lib.$post({
	        url: '/newCode',
	        method: 'post',
			data:{phone}
	      });
	    }
		/*
		    const ordernum = ctx.request.body.ordernum;
		    const ordername = ctx.request.body.ordername;
		    const total_fee = parseFloat(ctx.request.body.totalFee) * 100;
		    const attach = ctx.request.body.attach;
		*/
		this.getMiniProgramPayParams = async function(data) {
	      return await lib.$post({
	        url: '/getMiniProgramPayParams',
	        method: 'post',
			data
	      });
	    }
		this.arrival = async function(data) {
	      return await lib.$post({
	        url: '/arrival',
	        method: 'post',
			data
	      });
	    }
	  
	
};
HttpModule.prototype=Lib.prototype//继承Lib
export default HttpModule
